<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.io.*,java.util.*,java.sql.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%
	String email = request.getParameter("email");
	String username = request.getParameter("username");
	String password = request.getParameter("password");
	String gender = request.getParameter("sex");
	String telephone = request.getParameter("telephone");
	String profile = request.getParameter("profile");
	
	try {
		Class.forName("com.mysql.jdbc.Driver");
		Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/bookstore", "root", "");
		Statement stmt = conn.createStatement();
		String insertSql = "insert into user(username,PASSWORD,gender,email,telephone,introduce,role) values";
		
		insertSql += "(";
		insertSql += "\"" + username + "\",";
		insertSql += "\"" + password + "\",";
		insertSql += "\"" + gender + "\",";
		insertSql += "\"" + email + "\",";
		insertSql += "\"" + telephone + "\",";
		insertSql += "\"" + profile + "\",";
		insertSql += "\"user\"";
		insertSql += ")";
		
		out.print(insertSql);
		
		stmt.executeUpdate(insertSql);
		stmt.close();
		conn.close();
		
		response.sendRedirect("./registersuccess.jsp");
	} catch (Exception e) {
		out.print(e.toString());
	}
%>